package cn.wangqi.personal.util;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.io.Serializable;
import java.util.List;

/**
 * Created by admin on 2017/9/8.
 */
public class PageResultModel<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    @JsonProperty("cp")
    private int pageNo;
    @JsonProperty("pc")
    private int pageCount = -1;
    private int total;
    private int pageSize;
    @JsonProperty("l")
    private List<T> dataList;

    public PageResultModel() {
    }

    public int getPageNo() {
        return this.pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageCount() {
        if(this.pageCount == -1) {
            this.pageCount = StringUtil.getPageCount(this.total, this.pageSize);
        }

        return this.pageCount;
    }

    public int getTotal() {
        return this.total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getDataList() {
        return this.dataList;
    }

    public void setDataList(List<T> dataList) {
        this.dataList = dataList;
    }
}

